﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;

namespace Lavka.Core
{
    public static class TextHelper
    {
        public static string GetShortTextPreview(string text)
        {
            string shortText = "";
            if (!string.IsNullOrEmpty(text) && text.Length > 200)
            {
                shortText = StripHtml(text);
                return shortText.Substring(0, 200)+"...";
            }
            return text;
        }
        private static string StripHtml(string source)
        {
            string output;
            //get rid of HTML tags
            output = Regex.Replace(source, "<[^>]*>", string.Empty);
            //get rid of multiple blank lines
            output = Regex.Replace(output, @"^\s*$\n", string.Empty, RegexOptions.Multiline);
            return output;
        }
    }
}